package com.roc.jpamysql.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.roc.jpamysql.dto.req.SaveCityReq;
import com.roc.jpamysql.model.City;
import com.roc.jpamysql.dao.CityMapper;
import com.roc.jpamysql.service.ICityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author roc
 * @since 2024-03-23
 */
@Service("myCity")
@DS("roc")
public class CityServiceImpl extends ServiceImpl<CityMapper, City> implements ICityService {

    @Transactional(rollbackFor = Exception.class)
    public boolean saveCity(SaveCityReq saveCityReq) {
        City city = new City();
        BeanUtils.copyProperties(saveCityReq,city);
        return this.save(city);
    }
}
